import {SETPROFILEACTION, SETPROFILEEDITACTION, UPDATEUSERINFO} from "@/store/actionTypes";

const initState = {
  user: {},
  profileInfo: {}
}


// 用于修改数据的reducer
const profileReducer = (state = initState, action) => {
  switch (action.type) {
    case SETPROFILEACTION:
      return {
        ...state,
        user: action.payload
      }
    case SETPROFILEEDITACTION:
      return {
        ...state,
        profileInfo: action.payload
      }
    //   更新用户信息数据
    case UPDATEUSERINFO:
      return {
        ...state,
        profileInfo: {
          ...state.profileInfo,
          // {photo: 'http://www.baidu.com'}
          ...action.payload
        }
      }
    default:
      return state
  }
}

export default profileReducer
